package main

import (
	"gobuild/config"
	_ "gobuild/routers"
	"log"
	"os"
	"path/filepath"
	"strings"

	"github.com/astaxie/beego"
	"github.com/voxelbrain/goptions"
)

func getCurrentDirectory() string {
	dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
	if err != nil {
		log.Fatal(err)
	}
	return strings.Replace(dir, "\\", "/", -1)
}

func main() {
	options := struct {
		HomePath string        `goptions:"-H, --home, description='Home Path'"`
		Help     goptions.Help `goptions:"-h, --help, description='Show this help'"`
	}{HomePath: getCurrentDirectory() + "/GOBUILD_HOME"}
	goptions.ParseAndFail(&options)

	//初始化Home目录
	config.InitHome(options.HomePath)
	//启动
	beego.Run()
}
